-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make a default global location for custom user templates #1028
Conversation
@t-makaro @maartenbreddels it could be interesting for nbconvert to adopt a template system similar to that of voila, where a template and corresponding resources are placed into a subdirectory of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many +1's. This is a nice quality of life improvement. @SylvainCorlay do you believe we should do more now from your comment or would you be good with us merging this and maybe extending the idea later?
@MSeal @t-makaro I am +1 on a default global location for templates, but not in the configuration directory. IMO, it should be in the Jupyter already has the machinery in |
This would play much better with template managers as well. Would you guys like to have a quick chat with us about this? We have put some thoughts on how we could make this work with @maartenbreddels, also with the lessons learned from other extension points such as widgets. |
Yes, I think it would be great if we can align these two systems. It would be great if people using voila and nbconvert only have to learn 1 system. |
I'd be down for a quick chat on the topic. What's easiest tech / time for folks? We have a zoom channel we use for nteract weekly syncs that's readily available. |
@MSeal that's a good idea, maybe thursday or friday would be possible? I also have some plans for voila to allow progressive loading (write out HTML ASAP to the client so it can render and fetch resources in parallel): In an ideal world, we would have:
|
@MSeal, @maartenbreddels Any time on thursday would work for me. |
After 2:30 US/Pacific time I'm still free for Thursday.
…On Tue, May 28, 2019 at 1:54 PM Tyler Makaro ***@***.***> wrote:
@MSeal <https://github.com/MSeal>, @maartenbreddels
<https://github.com/maartenbreddels> Any time on thursday would work for
me.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1028?email_source=notifications&email_token=AAOHBVEY7HFY57KXCGEPDLLPXWLYLA5CNFSM4HN5KAT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWNNHBY#issuecomment-496685959>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOHBVHRAKDODZ5NB3PR7ATPXWLYLANCNFSM4HN5KATQ>
.
|
2:30 PDT at https://zoom.us/j/795404957 then (let me know if another time would be better) |
2:30 PDT is 23:30 (CEST), which is currently too late for me. Sunday late (20:00-22:30 window in CEST) might be an option for me, but cannot speak for @SylvainCorlay. Between now and an hour from now is also possible. |
I think I would be free 20:00 CEST (18:00 UTC), I have plans for that day that might collide. Would a little earlier be possible? Maybe 19:00 CEST (17:00 UTC) on Sunday? |
I could make that time (19:00 CEST (17:00 UTC) on Sunday) work. But perhaps we could schedule a time to chat as part of the workshop next week? It seems deeply apropos. |
I can make 17:00 UTC on Sunday work too, or anytime Tuesday/Wednesday next week. Some other times next week may work as well, but I'm not sure yet. |
17:00 UTC Sunday then? |
I'll arrive at my stay in Paris at ~17:00 UTC, so I might be a bit later, 17:15 at the latest I think. I'll leave it up to you if you want to start later or wait for me. |
A couple of us are on the call now fyi |
Sorry I cannot make it (on a train with a terrible connection) but I trust maarten to present the approach in voila. We did some brainstorming about this at the kernels workshop. |
It seems that we will make some template changes in a few steps. The first step will be some path changes that I will update this PR with. I will add both a config directory location and a data directory location for templates. |
Just one question about implementing the data files path. Do we want just the one path returned from For the config directory, I am only searching the one path returned from On my windows machine
|
Ideally I think we should move to "all the paths from the list" in priority ordering, much like how PYTHONPATH works. |
In voila we use FYI, we're gonna have a discussion about this again tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use a unittest, but given it's all config I'll leave it to you if you want to merge as is.
Quick question: what is the rationale for using a configuration path instead of a data path? |
Could we iterate on this a bit more? We're working out the details for voila and I'd like to see how we can unite this very soon. voila-dashboards/voila#208 |
@SylvainCorlay A configuration directory is good for users who wish to make their own templates to configure a couple of things. Many people ask about configuration opptions that are currently only possible with templates. The config directory is a natural location for these people. Personally, I sync my configuration directory between multiple computers, so this acts as a global location for user templates. @maartenbreddels This PR is meant for nbconvert 5.6. I will strip be ok to strip out the @MSeal I added a test that creates a template file within the configuration directory and then attempts to use it. If the test passes, it's ready to merge. It not, I'd like to remove the test and merge as is. It was a little annoying to get this test to pass on windows. |
But this appears to be just as simple to do with a template in a data directory. Templates don't have to be very complicated. Also, it sort-of breaks the unix-style pattern in terms of what configuration vs data directory are for. Besides, nbconvert templates will probably soon need to be more than just a jinja template, but an entire directory with more resources. One common use case in my experience is that you may want to couple python configuration changes with the choice of a template. For example, in the case of an HTML exporter template, the CSS to be inlined in the header depends on the template... Right now it is hard-coded in the back-end implementation. I am -1 on having templates in the configuration directory because it will be hard to support going forwards. |
I don't think this makes maintaining any more complicated, but it does make the user experience nicer. Templates are relatively environment independent, but the data directories are not, so I sync my configuration directory between computers but not my data directory. Configuration directory for user changes, and the data directory for developers to install data to.
|
I would argue that the choice of the template itself is configuration, but not the template itself.
Package managers are really bad at dealing with configuration. |
I'm a bit torn between the using I've been checking what other software does, and according to https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html (or the more human readable version https://askubuntu.com/questions/14535/whats-the-local-folder-for-in-my-home-directory) says to use So I have to agree with Sylvain here, using I propose we leave out the
Is cwd in the search path? I don't see that in the code, but that could be useful for voila as well. |
Alright, so where are we on action items for this PR? I think I can agree to the logic @maartenbreddels and @SylvainCorlay layed out for config / data directory choices. @t-makaro do we need to discuss more options for making your use case more convenient? |
Sorry for the long delay.
@maartenbreddels template_path=List([.]) defines a list of extra paths to find templates and defaults to the cwd. @MSeal I think I can make it work so long as the I believe this is ready to merge. |
Awesome. Yes this look solid and we can adjust if the viola devs want to add things later. No problem on the delay, I've similarly been our of sync with tasks. |
This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/nbconvert-5-6-0-release/1867/1 |
Did this resolve the location for custom templates? If so, how is it handled where does one set the location for custom templates? See #1428 for more details |
Responded on the new issue you made |
Fixes jupyter#1430 Many users are reporting that nbconvert 6.x has permission errors when queried or converting files. These seem to arise when nbconvert is installed as root, then used as a user. We hypothesize that the code removed in this commit, which attempts to create template directories throughout the jupyter path hierarchy, succeeds in creating template directories when running as root. Note that it creates the template directories with permission 700. Those permissions as root mean that regular users won’t be able to read these directories, and those are the sort of permission errors we are seeing reported. This directory creation was originally introduced in jupyter#1028, where I think it was limited to a single user configuration directory (based on the PR discussion). In jupyter#1056, this code appears to have been copied over and applied to the entire Jupyter directory hierarchy.
* Do not attempt to create additional template paths. Fixes #1430 Many users are reporting that nbconvert 6.x has permission errors when queried or converting files. These seem to arise when nbconvert is installed as root, then used as a user. We hypothesize that the code removed in this commit, which attempts to create template directories throughout the jupyter path hierarchy, succeeds in creating template directories when running as root. Note that it creates the template directories with permission 700. Those permissions as root mean that regular users won’t be able to read these directories, and those are the sort of permission errors we are seeing reported. This directory creation was originally introduced in #1028, where I think it was limited to a single user configuration directory (based on the PR discussion). In #1056, this code appears to have been copied over and applied to the entire Jupyter directory hierarchy. * Filter additional template paths to existing paths to be consistent.
Right now there are some barriers for users to configure nbconvert with custom templates. This PR makes exporters search for custom templates within the Jupyter configuration directory (
~/.jupyter/nbconvert/templates
). This gives users a nice place to store their custom templates without needing to alterTemplateExporter.template_path
in order to have a location where templates are globally accessible.I also added some documentation about this new location for storing templates, and I added some detail to documentation around jinja and LaTeX.
The configuration directories for the templates are automatically created. I tried my best to follow what Jupyter notebook/jupyter_core/traitlets does for creating directories like these.